(function() {

this.pasta = this.pasta || {};
this.pasta.util = this.pasta.util || {};

this.pasta.util.Font = Class.extend(
{
	init : function() 
	{
		this.bold = false;
		this.underline = false;
		this.italics = false;
		this.size = 12;
		this.fontName = '"Trebuchet MS", Arial, Helvetica, sans-serif';
		this.color = "#000000";
		
		this._onChange = null;
	},
	
	applyFont : function(canvas)
	{
		canvas.style.fontWeight = this.bold ? "bold" : "normal";
		canvas.style.fontSize = this.size + "px";
		canvas.style.color = this.color;
		canvas.style.fontFamily = this.fontName;
		canvas.style.textDecoration = this.underline ? "underline" : "";
		canvas.style.fontStyle = this.italics ? "italic" : "normal";
	},
	
	wrapHTML : function(data, id) 
	{
		var result = data;
		
		if (this.bold)
			result = "<b id='" + id + "'>" + result + "</b>";
		
		if (this.underline)
			result = "<u id='" + id + "'>" + result + "</u>";
		
		if (this.italics)
			result = "<i id='" + id + "'>" + result + "</i>";
		
		return result;
	},
	
	isBold : function() 
	{
		return this.bold;
	},
	
	setBold : function(data) 
	{
		this.bold = data;
		
		if (this._onChange != null)
			this._onChange.callHandler(this);
	},
	
	isUnderline : function() 
	{
		return this.underline;
	},
	
	setUnderline : function(data) 
	{
		this.underline = data;
		
		if (this._onChange != null)
			this._onChange.callHandler(this);
	},
	
	isItalics : function() 
	{
		return this.italics;
	},
	
	setItalics : function(data) 
	{
		this.italics = data;
		
		if (this._onChange != null)
			this._onChange.callHandler(this);
	},
	
	getSize : function() 
	{
		return this.size;
	},
	
	setSize : function(data) 
	{
		this.size = data;
		
		if (this._onChange != null)
			this._onChange.callHandler(this);
	},
	
	getColor : function() 
	{
		return this.color;
	},
	
	setColor : function(data) 
	{
		this.color = data;
		
		if (this._onChange != null)
			this._onChange.callHandler(this);
	},
	
	getFontName : function() 
	{
		return this.fontName;
	},
	
	setFontName : function(data) 
	{
		this.fontName = data;
		
		if (this._onChange != null)
			this._onChange.callHandler(this);
	},
	
	//---------------------- Event ---------------
	
	getOnChange : function()
	{
		if (this._onChange == null)
			this._onChange = new pasta.util.EventObj();
			
		return this._onChange;
	}
});

})();